package com.base.myproject.client.busi.service;

import java.util.ArrayList;
import java.util.List;

import com.base.myproject.client.ui.celleditor.BaseGridEditor;
import com.base.myproject.client.ui.codenamemap.CodeNameMapFactory;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;

public class Subtractfinace {
	String test;
	
	public Subtractfinace(){
		
	}
	
	public Subtractfinace(String text){
		this.test = test;
	}
	
	public void showDialog(){
		final Dialog d = new Dialog();
		d.setWidth("100");
		
		final FormPanel formpanel = new FormPanel();
		
		CodeNameMapFactory cnmf = new CodeNameMapFactory();
		
		// 会员号
		List<ColumnConfig> ccodecolumns = new ArrayList<ColumnConfig>();
		ColumnConfig membernum = new ColumnConfig("code", "会员编码", 100);

		ccodecolumns.add(membernum);

		ColumnConfig membername = new ColumnConfig("name", "会员名", 50);

		ccodecolumns.add(membername);
		final BaseGridEditor bge = new BaseGridEditor(ccodecolumns, cnmf
				.getBaseccodestore(), "name", "code");
		bge.setFieldLabel("会员号");
		
		// 消费金额
		final NumberField finacefield = new NumberField();
		finacefield.setAllowBlank(false);
		finacefield.setFieldLabel("消费金额");
		
		// 操作员
		List<ColumnConfig> bocodecolumns2 = new ArrayList<ColumnConfig>();
		ColumnConfig bcode2 = new ColumnConfig("code", "人员", 100);

		bocodecolumns2.add(bcode2);

		ColumnConfig bname = new ColumnConfig("name", "人员名", 50);

		bocodecolumns2.add(bname);
		final BaseGridEditor bge2 = new BaseGridEditor(bocodecolumns2, cnmf
				.getBasebcodestore(), "name", "code");
		bge2.setFieldLabel("操作员");
		
		// 密码 
		final TextField<String> pass = new TextField<String>();
		pass.setAllowBlank(false);
		pass.setFieldLabel("密码");
		pass.setPassword(true);
		
		// FORM
		formpanel.setLabelWidth(75);
		formpanel.setFieldWidth(100);
		//formpanel.setHeaderVisible(false);
		formpanel.setHeading("消费");
		
		formpanel.add(bge);
		formpanel.add(finacefield);
		formpanel.add(bge2);
		formpanel.add(pass);
		
		
		d.setSize(250, 220);
		d.add(formpanel);
		
		// CANCEL BUTTON
		d.setButtons(Dialog.OKCANCEL);
		d.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>(){

			@Override
			public void componentSelected(ButtonEvent ce) {
				d.setVisible(false);
			}
		});
		d.show();
	}
}
